package com.china08.yxyapi.api.manage.stu.mystudy.mistakes;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import com.china08.yxyapi.api.YxyApiBaseController;
import com.china08.yxyapi.entity.mg.mistakes.StuMistakesQuesNote;
import com.china08.yxyapi.model.YxyApiReqModel;
import com.china08.yxyapi.model.YxyApiRespModel;
import com.china08.yxyapi.repository.mg.mistakes.StuMistakesQuesNoteRepository;

/**
 * 错题本--学生端--笔记删除
 * 
 * @author LiuWeidong
 *
 */
@CrossOrigin
@RestController
public class StuMistakesQuesNoteDelController extends YxyApiBaseController {

    @Autowired
    StuMistakesQuesNoteRepository stuMistakesQuesNoteRepository;

    @RequestMapping(value = "/api_yw/manage/stu/mystudy/mistakes/note/del", method = RequestMethod.POST, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
    public void process(HttpServletRequest request, HttpServletResponse response, @RequestBody ReqModel model) {
        StuMistakesQuesNote stuMistakesQuesNote = stuMistakesQuesNoteRepository.findOne(model.id);
        Assert.notNull(stuMistakesQuesNote, "该笔记内容不存在！");
        stuMistakesQuesNoteRepository.delete(stuMistakesQuesNote);
    }

    /* 请求参数 */
    protected static class ReqModel extends YxyApiReqModel {
        // 笔记id
        public String id;
    }

    /* 响应参数 */
    protected static class RespModel extends YxyApiRespModel {

    }
}
